package com.xinyue.auto.reader.util;

import org.dom4j.Element;

import com.xinyue.auto.util.StringUtil;

public class ColumnUtil{
	private static String dec = ", ";//分隔符号
	private static String link = " = ";//连接符
	
	/**
	 * 合成column注解信息，值为字符类型，并返回注解属性值
	 * @param column
	 * @param value
	 */
	public static String compoundByName(StringBuilder column, Element prop, String name) {
		String value = prop.attributeValue(name);
		if(!StringUtil.isNull(value)) {
			column.append(dec + "name = \"" + value + "\"");
		}
		return value;
	}
	
	/**
	 * 合成column注解信息，值为非字符类型，并返回注解属性值
	 * @param column
	 * @param value
	 */
	public static String compound4String(StringBuilder column, Element prop, String name) {
		String value = prop.attributeValue(name);
		if(!StringUtil.isNull(value)) {
			column.append(dec + name + " = \"" + value + "\"");
		}
		return value;
	}
	/**
	 * 合成column注解信息，值为非字符类型，并返回注解属性值
	 * @param column
	 * @param value
	 */
	public static String compound(StringBuilder column, Element prop, String name) {
		String value = prop.attributeValue(name);
		if(!StringUtil.isNull(value)) {
			column.append(dec + name + link + value);
		}
		return value;
	}
}
